/*
 * Main.java
 *
 * Created on 4 de noviembre de 2006, 12:27
 *
 */

package cheers.app;

import java.util.List;
import cheers.gui.IApplicationFrame;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author santiago
 */
public class Main implements IMain {
    
    private String applicationName = "";
    private String applicationVersion = "0.0.0";
    private IApplicationFrame mainFrame = null;

    //<editor-fold defaultstate="collapsed" desc=" Spring Dependency Injection Setters ">
    public void setApplicationName(String title) {
        this.applicationName = title;
    }
    
    public void setMainFrame(IApplicationFrame mf) {
        this.mainFrame = mf;
    }
    
    public void setApplicationVersion(String v) {
        applicationVersion = v;
    }
    //</editor-fold>
    
    /**
     * This is the real run method
     */
    public void run(String[] args) {
        mainFrame.setApplicationName(applicationName);
        mainFrame.setApplicationVersion(applicationVersion);
        
        // launch the AWT event
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                mainFrame.run();
            }
        });

    }
    
    public static void main(String[] args) {
        String appContextFile = "applicationContext.xml";
        ApplicationContext appContext = 
                new ClassPathXmlApplicationContext( appContextFile );
        
        Main application = (Main)appContext.getBean("main");
        application.run(args);
    }
}
